package com.wenx.v3system.modular.platform.domain.dto;

import com.wenx.base.domain.BaseDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 平台租户DTO *
 * @author wenx
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "平台租户信息")
public class PlatformTenantDto extends BaseDto {

    @NotBlank(message = "租户编码不能为空")
    @Size(max = 50, message = "租户编码长度不能超过50个字符")
    @Schema(description = "租户唯一编码", example = "tenant_001")
    private String code;

    @NotBlank(message = "租户名称不能为空")
    @Size(max = 100, message = "租户名称长度不能超过100个字符")
    @Schema(description = "租户名称", example = "演示企业")
    private String name;

    @Schema(description = "租户域名", example = "demo.v3cloud.com")
    private String domain;

    @Schema(description = "租户Logo URL", example = "/logos/demo.png")
    private String logo;

    @Schema(description = "租户描述", example = "演示企业租户")
    private String description;

    @Schema(description = "联系人姓名", example = "张三")
    private String contactName;

    @Email(message = "联系人邮箱格式不正确")
    @Schema(description = "联系人邮箱", example = "contact@demo.com")
    private String contactEmail;

    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "联系人电话格式不正确")
    @Schema(description = "联系人电话", example = "13800138000")
    private String contactPhone;

    @Schema(description = "联系地址", example = "北京市朝阳区")
    private String address;

    @Schema(description = "租户状态：1-正常，2-试用，3-暂停，4-过期，0-禁用", example = "1")
    private Integer status;

    @Schema(description = "套餐类型", example = "basic")
    private String planType;

    @Schema(description = "最大用户数限制", example = "100")
    private Integer maxUsers;

    @Schema(description = "当前用户数", example = "25")
    private Integer currentUsers;

    @Schema(description = "过期时间")
    private LocalDateTime expireTime;

    @NotBlank(message = "数据库Schema名称不能为空")
    @Schema(description = "租户数据库Schema名称", example = "tenant_001_db")
    private String databaseName;

    @Schema(description = "数据库连接配置（JSON格式）")
    private String databaseConfig;

    @Schema(description = "功能配置（JSON格式）")
    private String featureConfig;

    @Schema(description = "租户设置（JSON格式）")
    private String settings;

    @Schema(description = "扩展元数据（JSON格式）")
    private String metadata;

    // 扩展字段（计算得到）
    @Schema(description = "用户使用率", example = "25.0")
    private Double userUsageRate;

    @Schema(description = "是否即将过期", example = "false")
    private Boolean isExpiringSoon;
} 